from django.conf import settings
import copy


class ModelsChoices:
    def __init__(self):
        self.MODELS_CHOICES = copy.deepcopy(settings.MODELS_CHOICES)

    def conversion_data(self, data):
        data = list(data)
        rdata = []
        for dt in data:
            rdata.append({'id': dt[0], 'value': dt[1]})
        return rdata

    def get_models_choices(self):
        for choices_key in self.MODELS_CHOICES:
            data = self.MODELS_CHOICES[choices_key]
            if isinstance(data, tuple):
                self.MODELS_CHOICES[choices_key] = self.conversion_data(self.MODELS_CHOICES[choices_key])
                continue
            for dt in data:
                data[dt] = self.conversion_data(data[dt])
        return self.MODELS_CHOICES
